using UnityEngine;

public class M1911CM : MonoBehaviour
{
	public Weapon weapon;

	public AudioSource audiosource;

	public AudioClip startAudio;

	public GameObject deployObject;

	public bool triggered;

	private void Update()
	{
		if (!triggered && weapon.ammo == 0)
		{
			float num = Mathf.Clamp(1.5f - DO.Campaign.playerHealth / 100f, 0.5f, 1f);
			float value = Random.value;
			if (num > value)
			{
				Invoke("Explosion", 0.2f);
			}
			triggered = true;
		}
		else if (weapon.ammo > 0)
		{
			triggered = false;
		}
	}

	public void Explosion()
	{
		Object.Instantiate(deployObject, weapon.player.transform.position, Quaternion.identity);
		audiosource.PlayOneShot(startAudio);
	}
}
